﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RootUI : MonoBehaviour {

    public static RootUI rootUI;

    public GameObject MainMenuCanvas;
    public GameObject Bg;
    public GameObject Panels;
    public GameObject Common;
    public GameObject PopUI;
    private Stack<GameObject> StackPanels = new Stack<GameObject>();

    /// <summary>
    /// 加载面板
    /// </summary>
    /// <param name="Panel"></param>
    public void PushInStack(GameObject Panel)
    {
        if (StackPanels.Count>0)
        {
            StackPanels.Peek().SetActive(false);
        }
        StackPanels.Push(Panel);
    }

    /// <summary>
    /// 删除面板
    /// </summary>
    public void DestoryInStack()
    {
        if (StackPanels.Count>0)
        {
            Destroy(StackPanels.Pop()); 
        }

        if (StackPanels.Count > 0)
        {
            StackPanels.Peek().SetActive(true);
        }
    }

    private void Awake()
    {
        rootUI = this;
    }

    // Use this for initialization
    void Start () {

    }
	
	// Update is called once per frame
	void Update () {
		
	}

}
